﻿using System;
using System.Collections.Generic;

namespace RotovapPlatform.Domain.Equipment.DeviceParameters
{
	/// <summary>
	/// 设备参数主类
	/// </summary>
	public class DeviceParametersEntity
	{
		/// <summary>
		/// 设备基本信息
		/// </summary>
		public DeviceInfo DeviceInfo { get; set; } = new DeviceInfo();

		/// <summary>
		/// 工艺参数
		/// </summary>
		public Dictionary<string, ProcessParameter> ProcessParameters { get; set; } = new Dictionary<string, ProcessParameter>();

		/// <summary>
		/// 电机列表
		/// </summary>
		public List<Motor> Motors { get; set; } = new List<Motor>();

		/// <summary>
		/// 泵列表
		/// </summary>
		public List<Pump> Pumps { get; set; } = new List<Pump>();

		/// <summary>
		/// 传感器列表
		/// </summary>
		public List<Sensor> Sensors { get; set; } = new List<Sensor>();
	}

	/// <summary>
	/// 设备信息类
	/// </summary>
	public class DeviceInfo
	{
		/// <summary>
		/// 设备名称
		/// </summary>
		public string Name { get; set; } = "旋转蒸发仪";

		/// <summary>
		/// 设备型号
		/// </summary>
		public string Model { get; set; } = "RP-5000";

		/// <summary>
		/// 序列号
		/// </summary>
		public string SerialNumber { get; set; } = "SN20230001";

		/// <summary>
		/// 固件版本
		/// </summary>
		public string FirmwareVersion { get; set; } = "1.0.0";
	}

	/// <summary>
	/// 工艺参数类
	/// </summary>
	public class ProcessParameter
	{
		/// <summary>
		/// 参数名称
		/// </summary>
		public string Name { get; set; }

		/// <summary>
		/// 单位
		/// </summary>
		public string Unit { get; set; }

		/// <summary>
		/// 最小值
		/// </summary>
		public double MinValue { get; set; }

		/// <summary>
		/// 最大值
		/// </summary>
		public double MaxValue { get; set; }

		/// <summary>
		/// 默认值
		/// </summary>
		public double DefaultValue { get; set; }

		/// <summary>
		/// 调整步长
		/// </summary>
		public double Step { get; set; }
	}

	/// <summary>
	/// 电机类
	/// </summary>
	public class Motor
	{
		/// <summary>
		/// 电机ID
		/// </summary>
		public string Id { get; set; }

		/// <summary>
		/// 轴ID
		/// </summary>
		public int AxisId { get; set; }

		/// <summary>
		/// 电机名称
		/// </summary>
		public string Name { get; set; }

		/// <summary>
		/// 电机参数
		/// </summary>
		public MotorParameters Parameters { get; set; } = new MotorParameters();

		/// <summary>
		/// 工作位置列表
		/// </summary>
		public List<WorkPosition> WorkPositions { get; set; } = new List<WorkPosition>();
	}

	/// <summary>
	/// 电机参数类
	/// </summary>
	public class MotorParameters
	{
		/// <summary>
		/// 每转脉冲数
		/// </summary>
		public int PulsesPerRevolution { get; set; } = 10000;

		/// <summary>
		/// 减速比
		/// </summary>
		public double GearRatio { get; set; } = 1.0;

		/// <summary>
		/// 电机旋转一周负载位移量
		/// </summary>
		public double DisplacementPerRevolution { get; set; } = 10.0;

		/// <summary>
		/// 最大速度
		/// </summary>
		public double MaxSpeed { get; set; } = 100.0;

		/// <summary>
		/// 最大加速度
		/// </summary>
		public double MaxAcceleration { get; set; } = 50.0;

		/// <summary>
		/// 最大减速度
		/// </summary>
		public double MaxDeceleration { get; set; } = 50.0;

		/// <summary>
		/// Jog模式运行速度
		/// </summary>
		public double JogSpeed { get; set; } = 25.0;

		/// <summary>
		/// 正向软限位
		/// </summary>
		public double SoftLimitPositive { get; set; } = 100.0;

		/// <summary>
		/// 负向软限位
		/// </summary>
		public double SoftLimitNegative { get; set; } = 0.0;

		/// <summary>
		/// 单位
		/// </summary>
		public string Unit { get; set; } = "mm";
	}

	/// <summary>
	/// 工作位置类
	/// </summary>
	public class WorkPosition
	{
		/// <summary>
		/// 位置名称
		/// </summary>
		public string Name { get; set; }

		/// <summary>
		/// 位置值
		/// </summary>
		public double Position { get; set; }

		/// <summary>
		/// 移动速度
		/// </summary>
		public double Speed { get; set; }

		/// <summary>
		/// 加速度
		/// </summary>
		public double Acceleration { get; set; }

		/// <summary>
		/// 减速度
		/// </summary>
		public double Deceleration { get; set; }
	}

	/// <summary>
	/// 泵类
	/// </summary>
	public class Pump
	{
		/// <summary>
		/// 泵ID
		/// </summary>
		public string Id { get; set; }

		/// <summary>
		/// 轴ID
		/// </summary>
		public int AxisId { get; set; }

		/// <summary>
		/// 泵名称
		/// </summary>
		public string Name { get; set; }

		/// <summary>
		/// 泵参数
		/// </summary>
		public PumpParameters Parameters { get; set; } = new PumpParameters();

		/// <summary>
		/// 工作模式列表
		/// </summary>
		public List<WorkMode> WorkModes { get; set; } = new List<WorkMode>();
	}

	/// <summary>
	/// 泵参数类
	/// </summary>
	public class PumpParameters
	{
		/// <summary>
		/// 最大速度
		/// </summary>
		public double MaxSpeed { get; set; } = 100.0;

		/// <summary>
		/// 最大加速度
		/// </summary>
		public double MaxAcceleration { get; set; } = 50.0;

		/// <summary>
		/// 最大减速度
		/// </summary>
		public double MaxDeceleration { get; set; } = 50.0;

		/// <summary>
		/// 流量
		/// </summary>
		public double FlowRate { get; set; } = 10.0;

		/// <summary>
		/// 单位
		/// </summary>
		public string Unit { get; set; } = "ml/min";
	}

	/// <summary>
	/// 工作模式类
	/// </summary>
	public class WorkMode
	{
		/// <summary>
		/// 模式名称
		/// </summary>
		public string Name { get; set; }

		/// <summary>
		/// 速度
		/// </summary>
		public double Speed { get; set; }

		/// <summary>
		/// 加速度
		/// </summary>
		public double Acceleration { get; set; }

		/// <summary>
		/// 减速度
		/// </summary>
		public double Deceleration { get; set; }
	}

	/// <summary>
	/// 传感器类
	/// </summary>
	public class Sensor
	{
		/// <summary>
		/// 传感器ID
		/// </summary>
		public string Id { get; set; }

		/// <summary>
		/// 传感器名称
		/// </summary>
		public string Name { get; set; }

		/// <summary>
		/// 传感器类型
		/// </summary>
		public string Type { get; set; }

		/// <summary>
		/// 传感器参数
		/// </summary>
		public SensorParameters Parameters { get; set; } = new SensorParameters();
	}

	/// <summary>
	/// 传感器参数类
	/// </summary>
	public class SensorParameters
	{
		/// <summary>
		/// 校准因子
		/// </summary>
		public double CalibrationFactor { get; set; } = 1.0;

		/// <summary>
		/// 偏移量
		/// </summary>
		public double Offset { get; set; } = 0.0;

		/// <summary>
		/// 单位
		/// </summary>
		public string Unit { get; set; }

		/// <summary>
		/// 最小值
		/// </summary>
		public double MinValue { get; set; }

		/// <summary>
		/// 最大值
		/// </summary>
		public double MaxValue { get; set; }

		/// <summary>
		/// 低报警阈值
		/// </summary>
		public double AlarmLowThreshold { get; set; }

		/// <summary>
		/// 高报警阈值
		/// </summary>
		public double AlarmHighThreshold { get; set; }
	}
}